﻿using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using System;

namespace Dotnet.Utils.Utility.Other
{
    public class PredicateHelper
    {
        public static Func<T, OutT> CreatePredicate<T, OutT>(string command)
        {
            var options = ScriptOptions.Default.AddReferences(typeof(T).Assembly);
            Func<T, OutT> predicate = CSharpScript.EvaluateAsync<Func<T, OutT>>(command, options).Result;

            return predicate;
        }
    }
}